package com.fuful.service;

import com.fuful.domain.Users;
import com.fuful.tools.DBHelper;

import java.util.Date;
import java.util.List;
import java.util.Map;

public class UsersService {

    public boolean register(){

        return false;
    }

    public Users login(String parUName, String parUpwd){
        String sql = "select * from Users where uname = '"+ parUName +"'";
        List<Map<String,Object>> data = DBHelper.query(sql);
        if(!data.isEmpty()){
            Map<String,Object> row = data.get(0);
            if(parUpwd.equals(row.get("upwd").toString())){
                return new Users(Integer.parseInt(row.get("uid").toString())
                        ,row.get("uname").toString()
                        ,row.get("upwd").toString()
                        ,(Date)row.get("addtime"));
            }
        }
        return null;
    }

}
